<?php
	$webRoot = $this->app->getWebRoot();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>IPv6链接状态监测</title>
<?php		
	css::import($webRoot . 'js/index/css/reset.css');
	css::import($webRoot . 'js/index/css/common.css');
	css::import($webRoot . 'js/index/css/state.css');
	js::import($webRoot . 'js/jquery-1.8.3.min.js', $config->version);
	js::import($webRoot . 'js/getToday.js', $config->version);
	js::import($webRoot . 'js/getCNDate.js', $config->version);
	js::exportConfigVars();			
?>
<script type="text/javascript">
	$(document).ready(function () {
        function getClientIpv6(){
			//alert(1);
			$.getJSON("http://v6.ipv6-test.com/api/myip.php?json&callback=?", function(result){
				//console.log(result);
				var ipv6 = result.address;
				$("#ip_address").empty();
				$("#ip_address").append("IPv6地址为：");
				$("#now_ip").empty();
				$("#now_ip").text(ipv6);
			});
		}
		getClientIpv6();
		function getClientIpv4(){
			//alert(3);
			var ipaddr = $("#now_ip").text();
			//alert(ipaddr);
			if(ipaddr == ''){
				//alert(4);
				$.getJSON("http://v4.ipv6-test.com/api/myip.php?json&callback=?", function(result){
					//console.log(result);
					var ipv4 = result.address;
					$("#ip_address").empty();
					$("#ip_address").append("IPv4地址为：");
					$("#now_ip").empty();
					$("#now_ip").text(ipv4);	
				});
			}
		}
		getClientIpv4(); 
    })
	
	function createLink(moduleName, methodName, vars, viewType)
	{
		if(!viewType) viewType = config.defaultView;
		if(vars)
		{
			vars = vars.split('&');
			for(i = 0; i < vars.length; i ++) vars[i] = vars[i].split('=');
		}
		if(config.requestType == 'PATH_INFO')
		{
			link = config.webRoot + moduleName + config.requestFix + methodName;
			if(vars)
			{
				if(config.pathType == "full")
				{
					for(i = 0; i < vars.length; i ++) link += config.requestFix + vars[i][0] + config.requestFix + vars[i][1];
				}
				else
				{
					for(i = 0; i < vars.length; i ++) link += config.requestFix + vars[i][1];
				}
			}
			link += '.' + viewType;
		}
		else
		{
			link = config.router + '?' + config.moduleVar + '=' + moduleName + '&' + config.methodVar + '=' + methodName + '&' + config.viewVar + '=' + viewType;
			if(vars) for(i = 0; i < vars.length; i ++) link += '&' + vars[i][0] + '=' + vars[i][1];
		}
		return link;
	}
	
	/**
	开始搜索页面函数
	*/
	function startSearch(moduleName, methodName){
		
		var args=arguments,
			src=location.href;
			vars = src.split('?')[1];	
			vars = vars.split('&');	
			
			var return_array=new Object();
			for(var i = 0; i < vars.length; i++) {
				var var_array=vars[i].split('=');
				return_array[var_array[0]]=var_array[1];
			}
			for(var j=2;j<arguments.length;j++){
				return_array[arguments[j]]=encodeURI($("#"+arguments[j]).val());
			}				
			delete return_array.m;
			delete return_array.f;
			delete return_array.t;//config.viewVar  是这个值，如是配置文件改变，这里相应改变
			var vars_config='';
			for(var k in return_array){
			   vars_config+=k;
			   vars_config+='=';
			   vars_config+=return_array[k]+"&";
			}
			vars_config=vars_config.substr(0,vars_config.length-1);
			console.log(vars_config);
			//console.log(createLink(moduleName,methodName,vars_config));
			location.href=createLink(moduleName,methodName,vars_config);
			//console.log(return_array);
			//console.log(arguments);
	}
</script>
<style type="text/css">
	.tb_tr_th{width:100%;height:45px;overflow:hidden;}
	.tb_tr_th_2{width:100%;height:45px;float:left;overflow:hidden;background:#ebebeb url(<?php echo $webRoot?>theme/default/images/down.png) no-repeat scroll right;}
	.tb_tr_th_2_unit{width:100%;height:45px;float:left;overflow:hidden;background:#e3e3e3 url(<?php echo $webRoot?>theme/default/images/down.png) no-repeat scroll right;}
	.tb_tr_th_2_area{width:100%;height:45px;float:left;overflow:hidden;background:#ebebeb url(<?php echo $webRoot?>theme/default/images/down.png) no-repeat scroll right;}
	#type_id{height:45px;width:120%;background:url(<?php echo $webRoot?>theme/default/images/down.png) no-repeat scroll right;border:0px;font-size:16px;color:#3385ff;font-weight:700;margin-left:6%;}
	#unit_id{height:45px;width:120%;background:url(<?php echo $webRoot?>theme/default/images/down.png) no-repeat scroll right;border:0px;font-size:16px;color:#3385ff;font-weight:700;margin-left:10%;}
	#area_id{height:45px;width:120%;background:url(<?php echo $webRoot?>theme/default/images/down.png) no-repeat scroll right;border:0px;font-size:16px;color:#3385ff;font-weight:700;margin-left:17%;}
	a:hover{color:blue;}
</style>
</head>

<body>
<div id="topOne" style="height: 150px;  background-image:url(<?php echo $webRoot?>theme/default/images/top-one.png);background-image: no-repeat; background-size:cover;">
<div id="wrap">
  <div id="top"> <img src="<?php echo $webRoot?>theme/default/images/whitelogo.png" class="logo"/>
    <div id="adress">
      <ul>
        <li> <span id="ip_address" style="color:#fff">您目前使用IPv6/IPv4地址</span></li>
        <li><span id="now_ip" style="color:#fff"></span></li>
      </ul>
    </div>
  </div>
  <div id="mainnavi" style="background-image:url(<?php echo $webRoot?>theme/default/images/navi-bg.png);">
    <ul>
      <li><a href="<?php echo $this->createLink('index','index_ipv6');?>" target="_blank"><b>首 页</b></a></li>
      <li><a href="<?php echo $this->createLink('index','update');?>" target="_blank"><b>巴南区IPv6升级网站</b></a></li>
      <li><a href="<?php echo $this->createLink('index','netaddress');?>" target="_blank"><b>IPv6网址导航</b></a></li>
      <li><a href="<?php echo $this->createLink('index','state');?>" class="current"><b>IPv6链接状态监测</b></a></li>
      <li><a href="<?php echo $this->createLink('index','test');?>" target="_blank"><b>IPv6相关测试</b></a></li>
      <li class="nobodor"><a href="<?php echo $this->createLink('index','faq');?>" target="_blank"><b>FAQ</b></a></li>
    </ul>

  </div>
  <div id="content">
    <table id="playlist" width="1200" border="1" >
      <caption>
      <img src="<?php echo $webRoot?>theme/default/images/Directory.png"/>
      </caption>
      <tr>
        <th width="95" height="45" bgcolor="#E3E3E3" scope="col">序 号</th>
        <th width="105" height="45" bgcolor="#EBEBEB" scope="col">
			<div class="tb_tr_th">
				<div class="tb_tr_th_2">
					<select name="type_id" id="type_id" onchange=startSearch('index','state','type_id')>
						<option value="all"  <?php if(isset($_GET['type_id'])&&$_GET['type_id']=="all"){echo 'selected="selected"';}?>>所属类别</option>
						<?php foreach($type_info as $key=>$val){?>
						<option value="<?php echo $val->type_id;?>" <?php if(isset($_GET['type_id'])&&$_GET['type_id']==$val->type_id){echo 'selected="selected"';}?>><?php echo $val->type_name?></option>
						<?php }?>
					</select>
					<!--<img src="<?php echo $webRoot?>theme/default/images/down.png" style="position:absolute;margin-top:-31px;margin-left:42px;">-->
				</div>			
			</div>	
		</th>
        <th width="177" height="45" bgcolor="#E3E3E3" scope="col">
			<div class="tb_tr_th">
				<div class="tb_tr_th_2_unit">
					<select name="unit_id" id="unit_id" onchange=startSearch('index','state','unit_id')>
						<option value="all" <?php if(isset($_GET['unit_id'])&&$_GET['unit_id']=="all"){echo 'selected="selected"';}?>>所属单位</option>
						<?php foreach($unit_info as $key=>$val){?>
						<option onClick=startSearch('index','state','unit_id') value="<?php echo $val->unit_id;?>" <?php if(isset($_GET['unit_id'])&&$_GET['unit_id']==$val->unit_id){echo 'selected="selected"';}?>><?php echo $val->unit_name?></option>
						<?php }?>
					</select>
					<!--<img src="<?php echo $webRoot?>theme/default/images/down.png" style="position:absolute;margin-top:-31px;margin-left:86px;">-->
				</div>			
			</div>
		</th>
        <th width="144" height="45" bgcolor="#EBEBEB" scope="col">
			<div class="tb_tr_th">
				<div class="tb_tr_th_2_area">
					<select name="area_id" id="area_id" onchange=startSearch('index','state','area_id')>
						<option value="all" <?php if(isset($_GET['area_id'])&&$_GET['area_id']=="all"){echo 'selected="selected"';}?>>所属区域</option>
						<?php foreach($area_info as $key=>$val){?>
						<option onClick=startSearch('index','state','area_id') value="<?php echo $val->id;?>" <?php if(isset($_GET['area_id'])&&$_GET['area_id']==$val->id){echo 'selected="selected"';}?>><?php echo $val->name?></option>
						<?php }?>
					</select>
					<!--<img src="<?php echo $webRoot?>theme/default/images/down.png" style="position:absolute;margin-top:-31px;margin-left:66px;">-->
				</div>			
			</div>
		</th>
        <th width="240" height="45" bgcolor="#E3E3E3" scope="col">网站名称</th>
        <th width="290" height="45" bgcolor="#EBEBEB" scope="col">网站地址</th>
        <th width="170" height="45" bgcolor="#E3E3E3" scope="col">IPv6链接状态</th>
      </tr>
<!--	  
      <tr>
        <td>1</td>
        <td>政府</td>
        <td>安信中保北京</td>
        <td>重庆</td>
        <td>重庆市巴南区商务局</td>
        <td>http://ipv6.bananshangwu.gov.cn/</td>
        <td bgcolor="#3385FF">正常运作</td>
      </tr>
      <tr>
        <td>2</td>
        <td bgcolor="#EBEBEB">政府</td>
        <td>安信中保北京</td>
        <td bgcolor="#EBEBEB">重庆</td>
        <td>重庆巴南区档案局</td>
        <td bgcolor="#EBEBEB">http://ipv6.cqbnda.com/</td>
        <td bgcolor="#5C9DFF">正常运作</td>
      </tr>
-->
      <?php $output = array_slice($sites_info_list, 0,22); foreach($output as $k => $item): ?>
		<tr>
			<td><?php echo $k+1;?></td>
			<td><?php echo $item->type_name;?></td>
			<td><?php echo $item->unit_name;?></td>
			<td><?php echo $item->area_name;?></td>
			<td><?php echo $item->sites_name;?></td>
			<td><a target="_blank" href="<?php echo $item->visit_type."://".$item->pre_v6.".".$item->main_domain."/ ";?>"><?php echo $item->visit_type."://".$item->pre_v6.".".$item->main_domain."/ ";?></a></td>
			<td
			<?php
				if($k%2==0){
					echo 'style="background-color:#3385FF"';
				}else{
					echo 'style="background-color:#5C9DFF"';
				}
			?>
			>
			<?php
				if($item->ipv6_status==1){
					echo '正常运作';
			   }else{
					echo '<font style="color:red">非正常运作</font>';
			   }
			?>
			</td>
		  </tr>
	  <?php endforeach;?>
	  <?php $output = array_slice($sites_info_list, 23,999); foreach($output as $k => $item): ?>
		<tr class="state_tr" style="display:none;">
			<td><?php echo $k+23;?></td>
			<td><?php echo $item->type_name;?></td>
			<td><?php echo $item->unit_name;?></td>
			<td><?php echo $item->area_name;?></td>
			<td><?php echo $item->sites_name;?></td>
			<td><a target="_blank" href="<?php echo $item->visit_type."://".$item->pre_v6.".".$item->main_domain."/ ";?>"><?php echo $item->visit_type."://".$item->pre_v6.".".$item->main_domain."/ ";?></a></td>
			<td
			<?php
				if($k%2==0){
					echo 'style="background-color:#3385FF"';
				}else{
					echo 'style="background-color:#5C9DFF"';
				}
			?>
			>
			<?php
				if($item->ipv6_status==1){
					echo '正常运作';
			   }else{
					echo '<font style="color:red">非正常运作</font>';
			   }
			?>
			</td>
		  </tr>
	  <?php endforeach;?>
    </table>
  </div>
  <div style="clear:both;"></div>
  <div id="bottom">
   <ul>
          <li class="li_more"><a href="javascript:void(0);" >更多……</a></li>
    <!--     
			<a href="web3-1.html" ><img src="<?php echo $webRoot?>theme/default/images/add.png" class="add"/></a>
			<li class="more"><a href="web3-1.html" target="_blank">新增IPv6网站</a></li>	
	-->
        </ul>
  </div>
  <div id="footer">
	<p>立普威陆（重庆）科技有限公司版权所有 - IPv6链接状态监测&nbsp;&nbsp;&nbsp;&nbsp;<script type="text/javascript">
		//页面访问量统计
		var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id='cnzz_stat_icon_1257160509'%3E%3C/span%3E%3Cscript src='" + cnzz_protocol + "s11.cnzz.com/stat.php%3Fid%3D1257160509%26show%3Dpic' type='text/javascript'%3E%3C/script%3E"));
	</script></p>
	
  </div>
</div>
  </div>
<script type="text/javascript" language="JavaScript">
<!--
var Tb = document.getElementById("playlist");
if (Tb!= null)
{
	for (var i=0;i<Tb.rows.length ;i++ )
	{
		if (Tb.rows[i].rowIndex%2==1)
		{
			Tb.rows[i].style.backgroundColor="#ffffff";
		}
		else
		{
			Tb.rows[i].style.backgroundColor="#e3e3e3";
		}
	}
}
$(".li_more").click(function(){
	$(".state_tr").show();
	$(".li_more").click(function(){
		alert("已显示全部内容！");
	});
});

//-->

</script>
</body>
</html>
